package Client;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Event;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.TextArea;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;

public class FrameChat extends JFrame
{
	private JButton btSend;
	private TextArea jtextShow, jtextWrite;
	private JList lsUser;
	private JPanel pnAdd;
	private GridBagLayout gb;
	private GridBagConstraints gbc;
	
	public frameClient1()
	{
		super("Chat");
		initComponent();
	}	
	@SuppressWarnings("deprecation")
	private void initComponent()
	{
			setBounds(10,10,600,400);
			gb = new GridBagLayout();
			setLayout(gb);
			gbc = new GridBagConstraints();
			jtextShow = new TextArea("",15,50);
			jtextShow.setEditable(false);
			jtextWrite = new TextArea("",5,50);
			btSend = new JButton("Send");
			btSend.addActionListener(new ActionListener(){
				@Override
				public void actionPerformed(ActionEvent arg0) {
					EventQueue.invokeLater(new Runnable()
					{
						@Override
						public void run() {
							jtextShow.append(jtextWrite.getText());
						}
					});
				}			
			});
			gbc.fill = GridBagConstraints.BOTH;
			addComponent(jtextShow,0,0,4,1,GridBagConstraints.NORTHWEST);
			gbc.fill = GridBagConstraints.BOTH;
			addComponent(jtextWrite,5,0,1,3,GridBagConstraints.SOUTHWEST);
			gbc.fill = GridBagConstraints.RELATIVE;
			addComponent(btSend,5,1,1,1,GridBagConstraints.WEST);

			
	}
	public void addComponent(Component c, int row, int col, int nrow, int ncol, int ach)
	{
		gbc.gridx = col;
		gbc.gridy = row;
		
		gbc.weightx = ncol;
		gbc.weighty = nrow;
		
		gbc.anchor = ach;
		
		gb.setConstraints(c, gbc);
		add(c);
	}
}
